﻿using System;

namespace SymbolIntegration.core.Helpers
{
    public static class MathHelper
    {
        public const double k_Epsilon = 0.000000001;
        public static bool AlmostEqual(double lValue, double rValue)
        {
            return Math.Abs(lValue - rValue) < k_Epsilon;
        }

        public static bool IsInteger(double value)
        {
            double result = value > 0 ? value + k_Epsilon : value - k_Epsilon;
            return AlmostEqual((int) result, value);
        }

        public static int GetAsInteger(double value)
        {
            double result = value > 0 ? value + k_Epsilon : value - k_Epsilon;
            return (int) result;
        }
    }
}